open Format
open Utils.Error
open Utils.Pervasive
open Utils.RandSelect
open Syntax
open Pointers
open Binding
open Core
open PrintExpr
open GPUtils


module Gene : sig
	type delete_status = NoDelete | Delete | NoSpec
	type gene = {
		expression : term;
		gene_id : int;
		
		mutable protection : delete_status; 
		mutable geneFitness : float;	
		mutable scoreOfBestCarrier : float;
		mutable selectionProb : float;
		mutable useInPopulation : int;
		mutable seedSelectionCount : int
	}
	val gene_to_expression : gene -> t_Expr
	val new_gene : ?selectionProb:float -> ?ds:delete_status -> term->int->gene
end


module GenePool : sig
	exception BlockConstructionFailure

	type gene_category_info = {
		mutable species_use : int;
		mutable total_fitness : float;
		mutable next_gene_id : int
	}
	type gene_pool = {
		g : (ty, (gene_category_info * Gene.gene list)) Hashtbl.t;
		mutable ctx : context ref
	}
	
	(*gene pool operations **************************************************)
	val reset_values : gene_pool->unit
	val rem_type : gene_pool->ty->unit	
	val replace_type : gene_pool->ty->gene_category_info option->Gene.gene list option->unit
	
	val tyMem : gene_pool->ty->bool
	val tyFind : gene_pool->ty->(gene_category_info * Gene.gene list)
	val teMem : gene_pool-> term -> bool
	val teFind : gene_pool-> term -> Gene.gene
	
	val get_genes : gene_pool -> Gene.gene list 
	val get_types : ?pred:(ty->bool) -> gene_pool -> ty list 
	val get_term : gene_pool->ty->int->term
	val get_terms : ?predTe:(term->bool)-> ?predTy:(ty->bool)->gene_pool->term list
	
	val make_gene_pool : context ref -> gene_pool
	val insert_expression :  ?ds : Gene.delete_status ->gene_pool->t_Expr->unit
	val is_gene_expression : gene_pool->t_Expr->bool
	
	val comp : gene_pool->int
	val gene_count : gene_pool->int
end






 
(*val card : gene_pool->int

val make : context ref -> gene_pool 



					
val rand_ty : gene_pool->ty
val rand_te : ?ty_opt:(ty option)->gene_pool->term
val rand_func_from :  gene_pool -> ty -> term
val rand_func_to : gene_pool -> ty -> term
val rand_expr : gene_pool -> t_Expr
*)
